<template>
	<view class="page-wrap">
		<view class="box_bg"
			:style="'background: url('+ u_imgPath + 'shouye/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">

		</view>
		<view class="box_bg1">
			<view class="top-bg">
				<image :src="c_imgPath + 'invite.png'" />
			</view>
			<view class="gzbox" @click="$refs.shuoming.open()">
				<image :src="c_imgPath+'guize.png'"></image>
			</view>

			<view class="card" style="height: 580rpx;"
				:style="'background: url('+ c_imgPath + 'box_bg.png'+ ') repeat-y 0 0 / 100% 100%;'">
				<view class="people_title">邀请好友有礼</view>
				<view class="people-money">
					<view class="people">
						<!-- <image :src="z_imgPath+'yyq.png'" style="height:27rpx;width: 109rpx;"></image> -->
						<text class="money_text">已邀请</text>
						<view class="num"> {{ total }} </view>
					</view>
					<view class="line"></view>
					<view class="moneys">
						<view class="content" @click="gotoPage('/pages/user/sy_jl')">
							<!-- <image :src="z_imgPath+'jl.png'" style="height:27rpx;width: 145rpx;"></image> -->
							<text class="money_text">奖励总额</text>
							<view class="money"> {{ commission }} </view>
						</view>
						<view class="icon">
							<image :src="z_imgPath+'point_right.png'" mode="scaleToFill" />
						</view>
					</view>
				</view>
				<button class="invite-btn" open-type="share"
					:style="'background: url('+ c_imgPath + 'btn.png'+ ') repeat-y 0 0 / 100% 100%;'">
					<!-- <image :src="z_imgPath+'invite-btn.png'" /> -->
					<text>去邀请好友</text>
					<!-- 去邀请好友 -->
				</button>
				<button class="invite-btn" @click="inviteBtn()"
					:style="'background: url('+ c_imgPath + 'btn.png'+ ') repeat-y 0 0 / 100% 100%;'">
					<!-- <image :src="z_imgPath+'invite-btn.png'" /> -->
					<text>分享海报</text>
					<!-- 去邀请好友 -->
				</button>
				<view class="bom_text">成功邀请好友 获得佣金奖励</view>
			</view>

			<view class="card two" style="margin-top: 60rpx;"
				:style="'background: url('+ c_imgPath + 'box_bg1.png'+ ') repeat-y 0 0 / 100% 100%'">
				<image :src="c_imgPath + 'yqjl.png'" class="title-img" style="height: 86rpx;width: 352rpx;"></image>
				<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
					@up="upCallback">
					<view class="list-wrap">
						<view v-for="(item, i) of listdata" :key="i" class="list-wrap-item"
							:style="'border:'+(i+1==listdata.length?'none':'')">
							<view class="content">
								<view class="avatar">
									<image :src="item.headimg" mode="scaleToFill" />
								</view>
								<view class="info">
									<view class="info-hd">
										<text style="color: #fff;">{{ item.nickname }}</text>
										<text class="title">累计消费</text>
									</view>
									<view class="info-bd">
										<text>{{ item.addtime }}</text>
										<text class="money">¥{{ item.commission_money }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</mescroll-body>
			</view>
		</view>

		<uni-popup ref="shuoming" type="center">
			<view class="pop" :style="'background: url('+ c_imgPath + 'gz_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
				<view class="pop_title">规则说明</view>
				<view class="pop_con">
					<scroll-view scroll-y="true" style="height: 440rpx;">
						<view v-html="news"></view>
					</scroll-view>
				</view>
			</view>
			<view class="shuoming_close" @click="$refs.shuoming.close()">
				<image :src="u_imgPath + 'detail/close.png'"></image>
			</view>
		</uni-popup>
		<uni-popup ref="showImg" type="center">
			<view class="show_img">
				<image :src="share_url" mode="widthFix" class="hb_image" v-if="share_url" @click="share_img()"></image>
				<!-- <view class="close" @click="back()">
					<image src="../../static/yfs/back.png" mode="widthFix"></image>
				</view> -->
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				z_imgPath: this.$z_img + 'mine/yaoqing/',
				c_imgPath: 'https://qt.yhemall.com/mine/yaoqing/',
				u_imgPath: 'https://qt.yhemall.com/',
				downOption: {
					auto: false
				},
				listdata: [],
				news: '',
				total: 0,
				logo_image: '',
				commission: 0,
				share_url: ''
			}
		},
		onShareAppMessage() {
			let that = this;
			return {
				title: "快来加入乐掏~",
				imageUrl: that.logo_image,
				path: "/pages/shouye/index?pid=" + uni.getStorageSync('userinfo').ID + '&from=' + uni.getStorageSync(
					'userinfo').from
			};
		},
		onLoad() {
			this.getDanye(9)
			this.getShareImg();
		},
		methods: {
			inviteBtn() {
				this.$refs.showImg.open();
				return false;
				var that = this;
				uni.showLoading({
					title: '合成图片中'
				});
				setTimeout(function() {
					uni.hideLoading();
				}, 3000);
			},
			getShareImg() {
				let that = this;
				that.req({
					url: 'user_share_card',
					success(res) {
						if (res) {
							that.share_url = res.msg;
						}
					}
				})
			},
			//海报
			share_img() {
				let that = this;
				uni.downloadFile({
					url: that.share_url,
					success(res) {
						console.log(res)
						uni.showShareImageMenu({
							path: res.tempFilePath,
							success(res) {
								console.log(res)
							},
							complete(end) {
								console.log(end)
								that.$refs.showImg.close();
							}

						})
					}
				})

			},
			getDanye(e) {
				let that = this;
				that.req({
					url: 'danye',
					data: {
						type: e
					},
					success(res) {
						if (res.status == 1) {
							that.news = res.data
						}
					}
				})
			},
			/*下拉刷新的回调 */
			downCallback() {
				// this.mescroll.resetUpScroll()
				this.loadData(1)
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'invitation',
					data: {
						page: pageNo,
					},
					success(res) {
						that.total = res.data.count
						that.commission = res.data.money
						that.logo_image = res.data.share_image
						that.mescroll.endByPage(res.data.data.length, res.data.last_page);
						if (pageNo == 1) {
							that.listdata = res.data.data;
						} else {
							that.listdata = that.listdata.concat(res.data.data);
						}
					}
				})
			},

		}
	}
</script>

<style lang="scss">
	.close>image {
		width: 50rpx;
	}

	.close {
		position: fixed;
		top: 90rpx;
		width: 50rpx;
		height: 50rpx;
		left: 20rpx;
	}

	.hb_image {
		width: 100%;
		/* height: 100%; */
	}

	.show_img {
		padding-top: 0;
		background: #ffffff;
		width: 100vw;
		min-height: 100vh;
		box-sizing: border-box;
	}





	button::after {
		border: none;
	}

	button {
		background-color: transparent;
		padding-left: 0;
		padding-right: 0;
		line-height: inherit;
		border-radius: 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}

	image {
		width: 100%;
		height: 100%;
	}

	.page-wrap {
		padding-bottom: 100rpx;
		padding-top: 183rpx;
		min-height: 100vh;
		box-sizing: border-box;

		/deep/.uni-navbar__content {
			z-index: 998;
		}


		.top-bg {
			width: 750rpx;
			height: 322rpx;
			position: absolute;
			left: 0;
			top: 0;

		}

		.card {
			position: relative;
			z-index: 1;
			margin: 150rpx auto 0;
			width: 712rpx;
			// height: 540rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			// background: #fff;
			padding: 10rpx 30rpx;

			.title-img {
				display: block;
				margin: 0 auto;
				margin-top: -80rpx;
			}

			.people_title {
				text-align: center;
				background: linear-gradient(0deg, #968EB9 0.78125%, #FFFFFF 100%);
				-webkit-background-clip: text;
				-webkit-text-fill-color: transparent;
				font-size: 32rpx;
				font-weight: bold;
				margin-top: 20rpx;
			}

			.people-money {
				display: flex;
				align-items: center;
				justify-content: space-evenly;
				margin: 0 60rpx;
				padding: 20rpx 0;
				border-radius: 10rpx;
				background: rgba(#000000, 0.2);
				color: #ffffff;
				margin-top: 40rpx;

				.money_text {
					font-size: 24rpx;
				}

				.people {
					flex: 1;
					display: flex;
					flex-flow: column nowrap;
					align-items: center;

					.num {
						margin-top: 10rpx;
						font-size: 36rpx;
						font-weight: 400;
						color: #fff;
					}
				}

				.line {
					height: 122rpx;
					width: 0;
					border-left: 1px solid rgba(255, 255, 255, 0.3);
				}

				.moneys {
					display: flex;
					align-items: center;
					justify-content: center;
					flex: 1;

					.content {
						display: flex;
						flex-flow: column nowrap;
						align-items: center;

						.money {
							margin-top: 10rpx;
							font-size: 36rpx;
							color: #fff;

							text {
								font-size: 28rpx;
								margin-left: 6rpx;
							}
						}
					}

					.icon {
						width: 20rpx;
						height: 32rpx;
						margin-left: 30rpx;
					}
				}
			}

			.invite-btn {
				width: 550rpx;
				height: 78rpx;
				margin: 10rpx auto 30rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 88rpx;
				border: none;
				margin-top: 20rpx;

				text {
					background: linear-gradient(0deg, #B75AFF 0%, #FFFFFF 100%);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					font-weight: bold;
				}
			}

			.bom_text {
				text-align: center;
				font-size: 24rpx;
				color: #fff;
			}
		}

		.two {
			margin-top: 30rpx;
			background: #151515;
			padding-top: 35rpx;
			// min-height: 790rpx;

			.tab-wrap {
				margin-top: 15rpx;
				padding: 0 30rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;
				background: #fff;
				// width: 100%;
				height: 88rpx;
				position: relative;

				.tab-item {
					font-size: 28rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					display: flex;
					justify-content: center;
					align-items: center;

					.bar {
						width: 48rpx;
						height: 4rpx;
						background: #61e3ff;
						border-radius: 2rpx;
						position: absolute;
						bottom: 15rpx;
						opacity: 0;
					}

					&.active {
						color: #222;

						.bar {
							opacity: 1;
						}
					}
				}
			}

			.list-wrap {
				// height: auto;
				// overflow: hidden;

				&-item {
					height: 140rpx;
					display: flex;
					flex-flow: column nowrap;
					justify-content: space-evenly;
					box-sizing: border-box;
					border-bottom: 1px solid rgba(255, 255, 255, 0.3);

					.content {
						display: flex;
						justify-content: space-between;
						padding: 0 30rpx;

						.avatar {
							width: 86rpx;
							height: 86rpx;
							border-radius: 50%;
							overflow: hidden;
							background: #eee;
						}

						.info {
							width: calc(100% - 110rpx);

							&-hd {
								display: flex;
								justify-content: space-between;
								align-items: center;

								font-size: 32rpx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #333333;

								.title {
									font-size: 24rpx;
									font-family: Source Han Sans CN;
									font-weight: 400;
									color: #999999;
								}
							}

							&-bd {
								margin-top: 10rpx;
								display: flex;
								justify-content: space-between;
								align-items: center;

								font-size: 24rpx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #999999;

								.money {
									color: #F37400;
									font-size: 28rpx;
								}
							}
						}
					}


				}
			}

			.show-more {
				height: 70rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.btn {
					display: flex;
					justify-content: center;
					align-items: center;

					font-size: 28rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;

					.icon {
						width: 24rpx;
						height: 24rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
	}

	.gzbox {
		width: 190rpx;
		height: 44rpx;
		position: absolute;
		top: 74rpx;
		right: 0;
	}

	.gzbox>image {
		width: 100%;
		height: 100%;
		// margin-right: 9rpx;
		// margin-left: 20rpx;
		position: relative;
		// top: 6rpx;
	}



	.pop_con {
		height: 440rpx;
		margin: auto;
		margin-top: 50rpx;
		padding: 0rpx 36rpx;
		font-size: 24rpx;
		line-height: 36rpx;
		color: #FFFFFF;
		box-sizing: border-box;
		overflow-y: scroll;
	}

	.pop_title {
		// font-family: 'zcq';
		font-size: 32rpx;
		height: 58rpx;
		margin-top: 10rpx;
		line-height: 58rpx;
		text-align: center;
		background: linear-gradient(0deg, #A98FD3 0%, #E7CBFF 50%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		font-weight: bold;
	}

	.pop {
		width: 543rpx;
		height: 801rpx;
		padding-top: 74rpx;
		box-sizing: border-box;
		/* background: #FFFFFF; */
		/* border-radius: 20rpx; */
	}
</style>